#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2018/8/21 20:19
# @Author  : yangdy
# @Email   : yangdy@egu360.com
# @File    : 中级-电话号码的字母组合.py
# @Software: PyCharm


class Solution:
    def letterCombinations(self, digits):
        """
        :type digits: str
        :rtype: List[str]
        """
        m = {
            '2': 'abc',
            '3': 'def',
            '4': 'ghi',
            '5': 'jkl',
            '6': 'mno',
            '7': 'pqrs',
            '8': 'tuv',
            '9': 'wxyz'
        }
        ans = []

        def work(ds='', ss=''):
            print('ds:', ds)
            if not ds or len(ds) <= 0:
                ans.append(ss)
                return
            print(ds, ss)
            for x in m[ds[0]]:
                work(ds[1:], ss+x)
        work(ds=digits)
        return ans


def main():
    solve = Solution()
    digits = '23'
    print(digits)
    print(solve.letterCombinations(digits))


if __name__ == '__main__':
    main()